package com.medishare.adapter;

import java.util.ArrayList;

import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.medishare.R;
import com.medishare.data.DataCallRecord;
import com.medishare.data.DataHeathTip;
import com.medishare.data.DataMediReminder;
import com.medishare.util.Utils;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

public class AdapterHealthTip extends BaseAdapter {
	private Context mContext;
	private ArrayList<DataHeathTip> mData;
	private LayoutInflater mInflater;
    public AdapterHealthTip(Context context,ArrayList<DataHeathTip> datas){
    	this.mContext = context;
    	this.mData = datas;
    	mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }
	@Override
	public int getCount() {
		return mData.size();
	}

	@Override
	public DataMediReminder getItem(int position) {
		mData.get(position);
		return null;
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
		DataHeathTip data = mData.get(position);
		if(convertView == null){
			convertView = mInflater.inflate(R.layout.listview_item_health_tip, null);
			holder = new ViewHolder();
			holder.updateTime = (TextView) convertView.findViewById(R.id.update_time);
			holder.remark = (TextView) convertView.findViewById(R.id.remark);
			convertView.setTag(holder);
		}else{
			holder = (ViewHolder) convertView.getTag();
		}
		holder.updateTime.setText(Utils.convertTime(data.getUpdateTime()));
		holder.remark.setText(String.format(mContext.getResources().getString(R.string.health_tip_remark, data.getName(),data.getRemark())));
		return convertView;
	}
    
	
	static class ViewHolder{
		public TextView updateTime;
		public TextView remark;
	}
	
	
	
}
